package com.woniu.util;

public class ResponseResult<T> {
    private String msg;
    private Integer code;
    private T data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /**
     * 成功的返回方法
     *
     * @param <T>
     * @return
     */
    public static <T> ResponseResult<T> ok(T data) {
        ResponseResult<T> response = new ResponseResult<T>();
        response.setCode(ResponseCodeEnume.SUCCESS.getCode());
        response.setMsg(ResponseCodeEnume.SUCCESS.getMsg());
        response.setData(data);
        return response;
    }

    /**
     * 失败的返回方法
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResponseResult<T> fail(T data) {
        ResponseResult<T> response = new ResponseResult<T>();
        response.setCode(ResponseCodeEnume.FAIL.getCode());
        response.setMsg(ResponseCodeEnume.FAIL.getMsg());
        response.setData(data);
        return response;
    }


}
